#include "const.h"

var_t v_findroot(const char *name) {
	const char *p, *b;
	uint32_t hash;
	var_t v, prnt;
	char buf[256];

	v = (var_t)0;

	b = name;
	while((p = strchr(b, '.')) != (char *)0) {
		i_strncpy(buf, sizeof(buf), b, p-b);
		b = &p[1];

		prnt = v;

		hash = v_hash(buf);
		if (!(v = v_findhash(prnt, hash)))
			v = v_newhash(prnt, buf, hash);
	}

	return v ? v : g_var_root;
}
